home *** CD-ROM | disk | FTP | other *** search
/ LOGIC Apps / Logic-APPLE_II_APPS.iso / pc / LOGIC Apple II 5.25" Library - DOS Part 7 / DOS203A.dsk / DMFE.ASSEMBLY ROUTINES.txt < prev    next >
Text File  |  2012-02-16  |  6KB  |  28 lines

  1.  
  2. CONVERT
  3.  
  4.      The source code for the assembly language routines is fairly well documented so I will only summarize each routine.
  5.  
  6.      CONVERTS main purpose is to encode and decode a characters data bytes to the basic array CH$(*).  Lines 11 to 24 (listing 3) show how the routine is invoked from basic.  The routine begins with the retrival of the mode and it's subsequent storage on the stack.  Next the value of the character to be edited is used as an index into the character set to determine the address of that particular character. To facillate reading and writing to the array CH$(*) it's pointer is located by calling the monitor routine PTRGET at $DFE3.  The mode is then recalled from the stack and compared to "R" or "W" for a match.  A syntax error is generated if a match is not found.
  7.  
  8.      The WRITE routine takes a character from the character set and converts it into a string array.  The routine begins by creating free space for the first entry [ CH$(0) ].  After calculating the pointer to the attribute (flag) byte and copying the default settings to the string buffer, the attribute byte is loaded into the (A) register.  A logical shift right (LSR) is performed on the (A) reg four times to test of the first four bits for a value of 1.  If the test is true then the string in the buffer is modified to reflect this.  When these tests are complete the string is copied from the buffer to the free space previously created.  This same type of test is carried out for each of the remaining data bytes where a "1" bit represents a plot and a "0" bit a noplot.  The difference being that the test is performed by using an arithmetic shift left (ASL) instruction to test the hi-bit first down to the low-bit last.
  9.  
  10.      The READ routine does essentially the same thing only in reverse.  The array CH$(*) is searched and memory bits are set accordingly.  After each flag in the attribute string is tested the carry is rotated into the (A) reg and saved on the stack.  When all four flags have been tested the (A) reg is rotated four more times to position the bits in their proper order.  It is then stored in the characters attribute byte.  The next 11 entries in the array CH$(*) are also tested like this except that each string is 8 characters long with each character representing one bit in the byte.
  11.  
  12.      The GETSPACE rouitne makes room for the new string and sets the appropriate variable pointers.  The COPY routines initialize the string buffer with the default values.  The GETADDR subroutine uses a multiplication algorithm taken from SCOTT ZIMMERMAN'S assembly language column (NIBBLE vol 7 issue 7) to determine the characters address in memory.  The INCVAR routine bumps the variable pointer for the array CH$(*) by 3 and the SETPTR routine copies the variable pointer to the temporary string descripter.  The INITSET routine initializes the character set to all zeros by using the monitor move routine.  The CLEAR1 and CLEAR2 routines are responsible for erasing the character from the hires screen by hploting across the editing box and the screen character with the color set to black.
  13.  
  14.  
  15. DOWNLOAD
  16.  
  17.      The download routine consists of two main parts.  The first part is responsible for converting the character set into a font file and the second part is responsible for downloading it to the printer.
  18.  
  19. The conversion from a character set to a font file begins with the neccessary translation of the charcaters attribute byte into one that the printer can understand.  After initialization of the file pointer ($A00) and a character counter, a loop is set up to calculate and retrieve each characters attribute byte for testing of the download bit.  If the result of the test is true then the attribute byte is saved on the stack and the file pointer is incremented by 13 (number of bytes per character).  The start column, end column, character width offset and descender are also set to their default values.
  20.  
  21.      Next, a test is made to see if the character is to be proportionally spaced.  The attribute byte is retrived from the stack, shifted left by one bit and a branch past the proportional calculations is taken if the carry is clear.  The attribute byte is then saved on the stack after it is shifted again to get the character width offset.  If the carry is set then no offset is required.  The start and end columns are calculated by testing each data byte for a value greater than zero.  The start column can not be any more than 7 and the end column may not be less then 4.  If they conflict with each other or the minimum width is less than 5 columns wide, the printer will automatically revert that character to a width of 11 columns.  After the start column is determined it is shifted left four times (multiplied by 16) to put it in the hi-order nibble.  The result is then stored back into the start column variable.  The end column is determined much the same way except that the eleventh column is tested first down to the third column last.  The result is then stored back into the end column variable.  Next the attribute byte is retrived from the stack and a dummy character width offset is shifted onto it.  This is done to counter-act the first logical shift right (LSR) instruction after it which pulls off the character width offset if the charcter is not proportional.
  22.  
  23.      The last test done is to determine if the character is be a descender.  The descender variable is set to zero for a descender or left at one twenty eight for no descender.  The characters attribute byte is determined by adding the descender plus the start column plus the end column. 
  24.  
  25.      The result is then stored in the first position of the characters space in the font file.  Next, after the 11 data bytes are copied from the character set to the font file a jump is taken to process the next character.  When all 255 characters have been tested a "00" is stored at the end of the file to signal the download (to printer) routine that it has reached the end of file.  The font files actual length is calculated and stored in the variable LEN to be used by the BASIC program.
  26.  
  27.  
  28.